import { Component, OnInit,Host,Optional,Inject } from '@angular/core';
import { StateService } from '../state.service';
//import { ValueService } from '../value.service';
import { RootService } from '../../root.service';
import { Hero } from '../hero';

@Component({
  selector: 'app-one',
  templateUrl: './one.component.html',
  styleUrls: ['./one.component.css'],
  providers:[{provide:StateService,useClass:StateService}]
})
export class OneComponent implements OnInit {


  /**
   * [constructor 依赖注入各种服务]
   * @param {StateService} private                 state   [注入组件注入器中的服务]
   * @param {RootService}  private                 root    [注入根模块注入器中的全局服务]
   * @param {string}       @Inject('ValueService') private title [注入所在模块注入器中的字符串常量]
   * @param {Hero}         @Inject(Hero)           private hero  [注入所在模块注入器中的常量Hero的实例]
   */
  constructor(private state:StateService,
  	          private root:RootService,
  	          @Inject('TITLE') private title:string,
  	          @Inject(Hero) private hero:Hero ) { }

  ngOnInit() {

  console.log('one 初始化',this.root,this.title,this.hero);
  	//this.state.setName('lewis');

  }

  ngOnChecked(){
  	alert('checked')
  }
  ngOnChanges(){
  	console.log('changes');
  }

}
